#ifndef VERIFYCODEWIDGET_H
#define VERIFYCODEWIDGET_H

#include <QWidget>
#include<QRandomGenerator>
#include<QPaintEvent>
#include<QDateTime>

class VerifyCodeWidget : public QWidget
{
    Q_OBJECT
public:
    explicit VerifyCodeWidget(QWidget *parent = nullptr);

    // 重写绘图事件. 绘制验证码
    void paintEvent(QPaintEvent *event) override;

    // ⿏标点击时也刷新验证码
    void mousePressEvent(QMouseEvent *event) override;

    // 刷新验证码
    void refreshVerifyCode();

    // 检测验证码是否匹配
    bool checkVerifyCode(const QString& code);

private:
    //随机数生成器
    QRandomGenerator randomGenerator;

    //保存随机数的值
    QString verifyCode = "";

    //生成验证码
    QString generateVerifyCode();
signals:
};

#endif // VERIFYCODEWIDGET_H
